home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / sun4beta.lha / Geomview / tools / inst < prev    next >
Encoding:
Text File  |  1993-12-13  |  1.2 KB  |  53 lines

  1. #! /bin/sh
  2.  
  3. # usage: inst FILE DIRECTORY
  4.  
  5. # Installs FILE in DIRECTORY, printing appropriate messages.
  6. # For use in binary distribution Makefiles.
  7.  
  8. path=$1
  9. dir=$2
  10. file=`basename $path`
  11.  
  12. # Make sure $path exists
  13. if [ ! -r $path ] ; then
  14.   echo "Error: File $path is missing and hence cannot be installed"
  15.   exit 1
  16. fi
  17.  
  18. # Make sure $dir is a directory that we have write permission in
  19. if [ ! -d $dir ] ; then
  20.   echo "Error: $dir does not exist or is not a directory; cannot install file $path"
  21.   exit 1
  22. fi
  23. if [ ! -w $dir ] ; then
  24.   echo "Error: Cannot write to directory $dir; cannot install file $path"
  25.   exit 1
  26. fi
  27.  
  28.  
  29. # See if $dir/$file already exists, and if so, try to remove it,
  30. # unless it's the same as $path
  31. if [ -r $dir/$file ] ; then
  32.   if [     `ls -i $dir/$file | awk '{print $1}'`  \
  33.     != `ls -i $path | awk '{print $1}'` ] ; then
  34.     if /bin/rm $dir/$file >&- 2>&- ; then
  35.       echo Removed previously existing $dir/$file
  36.     else
  37.       echo Error: cannot remove previously existing file $dir/$file
  38.       exit 1
  39.     fi
  40.   else
  41.     echo $file is already in $dir
  42.     exit 0
  43.   fi
  44. fi
  45.  
  46. # Now attempt to copy $path into $dir
  47. if cp $path $dir ; then
  48.   echo Installed $path in $dir
  49. else
  50.   echo Error: could not install file $path in $dir
  51.   exit 1
  52. fi
  53.